#include "include.h"
#include "gui/elementpainter.h"

#include "compile/debug_memoryleaks"

using namespace gui;
using namespace model;


ElementPainter::ElementPainter(GraphicPainter* p)
: painter(p)
{
}


ElementPainter::~ElementPainter()
{
}


void ElementPainter::paint(Element* element)
{
    if (element)
    {
        ElementTypeEnum type = element->getType();
        switch(type)
        {
            case ElementType_FLOOR:
            {
                this->paint((Floor*)element);
                break;
            }

            case ElementType_CONTAINER:
            {
                this->paint((ElementContainer*) element);

                break;
            }

            case ElementType_UNDEFINED:
            default:
            {
                break;
            }
        }

    }
}



void ElementPainter::paint(ElementContainer* container)
{
    if (container)
    {
        std::vector<Element*>::iterator it = container->child_elements.begin();
        for (it = container->child_elements.begin(); it!=container->child_elements.end(); ++it)
        {
            if ((*it))
            {
                this->paint( (*it));
            }
        }
    }
}



void ElementPainter::paint(Floor* floor)
{
    if (floor && painter)
    {
        painter->drawRect(floor->topleft, floor->bottomright);
    }
}
